package com.tanhua.model.mongo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.mapping.Document;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document("places")
// 声明一个索引，索引的名称就是：location_index , 索引的字段location，索引的类型：2dsphere
@CompoundIndex(name = "location_index", def = "{'location': '2dsphere'}")
public class Places {

    private ObjectId id;

    private String title;

    private String address;

    // 用来记录数据的地址位置
    private GeoJsonPoint location;
}